//
//  AppDelegate.m
//  AppleSignIn
//
//  Created by xingshuai on 2021/8/23.
//

#import "AppDelegate.h"

#import <AuthenticationServices/AuthenticationServices.h>

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    
    // 检查appleId登录情况
    if (@available(iOS 13.0, *)) {
        NSString *userIdentifier = @"钥匙串中取出的 userIdentifier";
        if (userIdentifier) {
            ASAuthorizationAppleIDProvider *appleIDProvider = [ASAuthorizationAppleIDProvider new];
            [appleIDProvider getCredentialStateForUserID:userIdentifier completion:^(ASAuthorizationAppleIDProviderCredentialState credentialState, NSError * _Nullable error) {
                switch (credentialState) {
                    case ASAuthorizationAppleIDProviderCredentialAuthorized:
                        // 苹果授权凭证良好
                        break;
                    case ASAuthorizationAppleIDProviderCredentialRevoked:
                        // 苹果授权凭证失效、去登录
                        break;
                    case ASAuthorizationAppleIDProviderCredentialNotFound:
                        // 未发现苹果授权凭证、去登录
                        break;
                    case ASAuthorizationAppleIDProviderCredentialTransferred:
                        // 苹果授权信息变动
                        break;
                }
            }];
        }
    }
    
    return YES;
}


@end
